Skip to content

Conversation

@MungoG
Copy link
Collaborator

@MungoG MungoG commented Nov 5, 2025

This is a replacement PR for #57 as the source branch had to be recreated.

@cppalliance-bot
Copy link

cppalliance-bot commented Nov 5, 2025

An automated preview of the documentation is available at https://78.beast2.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2025-11-13 14:50:35 UTC

@MungoG MungoG changed the title body_read_stream implementation body_read_stream implementation (replacement for PR 57) Nov 5, 2025
@MungoG MungoG marked this pull request as ready for review November 11, 2025 14:49
@MungoG MungoG force-pushed the issue-55-async-body-stream-impl-v3 branch 3 times, most recently from 13961ee to b0b43e2 Compare November 12, 2025 18:01
Comment on lines 154 to 178
auto lambda2 = [&](system::error_code ec, std::size_t n)
{
BOOST_TEST_EQ(n, body_length_);
BOOST_TEST(!ec.failed());
BOOST_TEST(pr.got_header());
BOOST_TEST(pr.is_complete());
invoked2++;
};

int invoked1 = 0;

auto lambda1 = [&](system::error_code ec, std::size_t n)
{
BOOST_TEST_EQ(n, 0);
BOOST_TEST_EQ(ec, asio::error::operation_aborted);
BOOST_TEST(pr.got_header() == (i >= header_length_));
BOOST_TEST(!pr.is_complete());
invoked1++;
// Append the remainder of the message and try again.
std::string remainder = msg_.substr(i);
ts.append(remainder);
brs.async_read_some(
buf.prepare(1024),
lambda2);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unnecessarily complicated. Do these handlers need to be invoked recursively? Couldn't the same coverage be achieved with a simpler case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split it into two to make it more readable, with an intervening test::run(ioc)

@MungoG MungoG force-pushed the issue-55-async-body-stream-impl-v3 branch from b0b43e2 to 9f34f0b Compare November 12, 2025 19:14
@MungoG MungoG force-pushed the issue-55-async-body-stream-impl-v3 branch from 9f34f0b to d7fdade Compare November 13, 2025 12:45
@MungoG MungoG force-pushed the issue-55-async-body-stream-impl-v3 branch from d7fdade to 3a6aa4a Compare November 13, 2025 13:04
{
namespace beast2
{

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting:

namespace boost {
namespace beast2 {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to force this with a custom .clang-format:

BraceWrapping:
  AfterCaseLabel:  true
  AfterClass:      true
  AfterControlStatement: Always
  AfterEnum:       true
  AfterExternBlock: true
  AfterFunction:   true
  AfterNamespace:  false
  AfterObjCDeclaration: true
  AfterStruct:     true
  AfterUnion:      true
  BeforeCatch:     true
  BeforeElse:      true
  BeforeLambdaBody: true
  BeforeWhile:     true
  IndentBraces:    false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBraces: Custom

std::string header_ = "HTTP/1.1 200 OK\r\n"
"Content-Length: 12\r\n"
"\r\n";

Copy link
Collaborator

@ashtum ashtum Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting:

    std::string header_ = 
        "HTTP/1.1 200 OK\r\n"
         "Content-Length: 12\r\n"
         "\r\n";

We use a single indent for each line break, I couldn't find a way to config this in the clang-format without breaking other stuff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is sufficiently unusual to be outside the scope of clang-format :-)
Done manually.

// Official repository: https://github.com/cppalliance/beast2
//

#ifndef BOOST_HTTP_IO_IMPL_BODY_READ_STREAM_HPP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BOOST_BEAST2...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch! fixing.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.65%. Comparing base (daf37da) to head (b445dc7).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #78      +/-   ##
===========================================
+ Coverage    37.13%   38.65%   +1.51%     
===========================================
  Files           41       42       +1     
  Lines         1535     1573      +38     
===========================================
+ Hits           570      608      +38     
  Misses         965      965              
Files with missing lines Coverage Δ
include/boost/beast2/impl/body_read_stream.hpp 100.00% <100.00%> (ø)
src/asio_io_context.cpp 0.00% <ø> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update daf37da...b445dc7. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

retained by the caller, which must guarantee that it remains
valid until the handler is called.
*/
explicit body_read_stream(AsyncReadStream& us, http_proto::parser& pr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace uses of us with s , including in the documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also make the formatting of the documentation match the docs in read.hpp.

@cppalliance-bot
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants